<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul {
      display: flex;
      list-style: none;
    }

    li {
      margin: 20px;
      cursor: pointer;
    }

    .active {
      border: 2px solid red
    }
  </style>
</head>

<body>
  <div id="app">
    =={{msg}}==={{index}}
    <!-- <button v-show="index==0?false:true" @click="index--">上一张</button>
    <button v-show="index==srcArr.length-1?false:true" @click="index++">下一张</button>
     -->
    <button v-show="index>0" @click="index--">上一张</button>
    <button v-show="index<srcArr.length-1" @click="index++">下一张</button>
    <button v-show="index<srcArr.length-1" @click="handle($event)">handle</button>

    <hr />
    <ul>
      <!-- <li v-for="item in srcArr" @click="btn(index,item)"> -->
      <li :key="item" :class="index==i?'active':''" v-for="(item,i) in srcArr" @mouseover="btn(i,item,$event)">
        <img style="width:50px" :src="item" alt="">
      </li>
    </ul>
    <img style="width:150px" :src="url" alt="">
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: 'hello  vue',
        srcArr: [
          './assets/10-01.png',
          './assets/10-02.png',
          './assets/11-00.gif',
          './assets/11-01.gif',
          './assets/11-02.gif',
          './assets/11-03.gif',
          './assets/11-04.png',
          './assets/11-05.png',
        ],
        url: './assets/10-01.png',
        index: 0
      },
      methods: {
        btn (i, item, e) {
          console.log(e);
          this.url = item
          this.index = i
        },
        handle (e) {
          console.log(e, 9);
        }
      }
    })

    // console.log(vm, 2222);
  </script>
</body>

面试题：

问题：解释一下key

回答：唯一标识符，具有唯一性，可以提升性能，

如何提升性能？

内部有算法比较，diff ,根据key的唯一值，只有有一个数据更新，那她就会根据这个唯一值进行查找找到后值更改这一项的值，如果不加key就会找到后全部重新在渲染一遍

</html>